<?php
/*
此页面主要用来关于验证，session,cookie，登录，退出登录等
*/
class Verify extends Controller {
	function Verify(){
		parent::Controller();
		$this->load->helper(array('url','function','common'));
		$this->load->library('form_validation');//表单验证
 		//调用前台公用Model
 		$this->load->model('Mhome');
	}
	
	//相关函数：redirecter($msg,$url,$delay=3);

	//注册验证
	function register(){
		  $this->form_validation->set_rules('realname', '真实姓名', 'required');
		  $this->form_validation->set_rules('password', '密码', 'required');
		  $this->form_validation->set_rules('password2', '确认密码', 'required');
		  $this->form_validation->set_rules('bank_account', '银行帐号', 'required');
		  $this->form_validation->set_rules('bank_account2', '确认银行帐号', 'required');
		  $this->form_validation->set_rules('mobile', '手机号码', 'required');
		  $this->form_validation->set_rules('qq', 'QQ号码', 'required');
		  $this->form_validation->set_rules('email', '电子邮件', 'required');
		 if ($this->form_validation->run() == true){
			$uid=$this->Mhome->create_member_uid();
			$username="CM".str_pad($uid[0]->uid, 6, "0", STR_PAD_LEFT);
			$msg="注册成功，请牢记你的会员ID:<b>".$username."</b>点击下面链接，系统将为您自动登录！";
			//注册成功，保存Session
			set_session("username",$username);
			//测试Session是否设置成功：$msg=get_session("username");
			redirecter($msg,"member/center",$delay="back");
		}else{
			//失败了，则显示原因
			redirecter(validation_errors(),"member/register",$delay=3);
	   }
	}
	
	//用户安全退出
	function member_logout(){
		unset_session("username");
		redirecter("您正在注销登录！","home");
	}

}//end C_home
/* End of file home.php */
/* Location: ./system/application/controllers/home.php */